import request from '@/utils/request'
export default {
  /**
   * @description: 获取单位列表 *代表必填
   * @param {String/Number} page *
   * @param {String/Number} size *
   * @param {Object} entity {componyId: 1} *
   * @param {String} order 排序方式 ASC DESC 默认ASC
   * @param {String} sort 自定义排序方式 'createTime'
   * @return {Array}
   */
  getPlantingUnitList(params) {
    return request.post("/v3/templateTenant/unit/queryPageByCondition", {
      page: params.page,
      size: params.size,
      sort: "timestamp",
      auditFlag: 1,
      entity: params.entity
    });
  },

  getunitlist(params) {
    return request.post("/v3/template/unit/queryPageByCondition", {
      page: params.page,
      size: params.size,
      sort: "timestamp",
      entity: params.entity
    })
  },
  /**
   * @description: 通过单位名称条件查询所有单位
   * @param null *
   * @return {Object}
   */
  getPlantingUnitListByCondition(params) {
    return request.post("/v3/templateTenant/unit/queryByCondition", {
      auditFlag: 1,
      unitName: params.unitName
    });
  },
  /**
   * @description: 通过单位id条件查询所有单位
   * @param null *
   * @return {Object}
   */
  getUnitByCondition(id) {
    return request.post("/v3/templateTenant/unit/queryByCondition", {
      auditFlag: 1,
      unitNo: id
    });
  },
  // 获取种养方式
  getmodeByCondition(fid) {
    return request.get(`/v3/template/putIntoMode/queryByFarmingTypeNo?farmingTypeNo=${fid}`);
  },
  /**
   * @description: 获取当前组织结构所有单位
   * @param null *
   * @return {Object}
   */
  getallBasicunitlist(params) {
    return request.post("/v3/templateTenant/unit/queryByCondition", {
      ...params,
      organizationNo: sessionStorage.organizationNo
    })
  },
  getallunitlist(params) {
    return request.post("/v3/templateTenant/unit/queryByCondition", {
      ...params,
      organizationNo: sessionStorage.organizationNo
    })
  },
  queryunitlist(no) {
    return request.get(`/v3/templateTenant/unit/queryByNo?no=${no}&organizationNo=${sessionStorage.organizationNo}`)
  },
  /**
   * @description: 新增单位信息
   * @param {Object} formData *
   * @return {Object}
   */
  addPlantingUnitInfo(list) {
    return request.post("/v3/templateTenant/unit/importPublicList", {
      list: list,
      organizationNo: sessionStorage.organizationNo
    });
  },
  /**
   * @description: 编辑单位信息
   * @param {Object} formData *
   * @return {Object}
   */
  editPlantingUnitInfo(formData) {
    return request.post("/v3/templateTenant/unit/edit", formData);
  },
  /**
   * @description: 批量删除单位
   * @param {String} plantingUnit *
   * @return {Array}
   */
  delPlantingUnitById(idlist) {
    return request.post(`/v3/templateTenant/unit/delListByNo`, {
      list: idlist,
      organizationNo: sessionStorage.organizationNo
    });
  },
  getAllBList() {
    return request.post(`/v3/template/unitType/queryByCondition`, {})
  },
  getAllsBList() {
    return request.post(`/v3/templateTenant/unitType/queryByCondition`, {})
  },
  // 审核
  addList(params) {
    return request.post("/v3/template/applyUnit/add", params);
  },
  // 审核
  editList(params) {
    return request.post("/v3/template/applyUnit/edit", params);
  },
  getList(params) {
    return request.post("/v3/template/applyUnit/queryByCondition", {
      ...params
    });
  }
};
